﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ElectrosLtdApplication.Models;
using Common.Views;

namespace ElectrosLtdApplication.Controllers
{
    public class LogEntriesController : MenusController
    {
        //
        // GET: /LogEntries/

        public ActionResult Index()
        {
            LogEntriesModel lem = new LogEntriesModel();
            return View(lem);
        }

        public PartialViewResult SortEntriesByDate()
        {
            List<FaultsView> logdates = new FaultsServ.FaultsServiceClient().SortEntriesByDate().ToList();
            return PartialView("_logentry", logdates);
        }

        public PartialViewResult FilterByLogDate(DateTime startDate, DateTime endDate)
        {
            List<FaultsView> searchdates = new FaultsServ.FaultsServiceClient().FilterByLogDate(startDate, endDate).ToList();
            return PartialView("_logentry", searchdates);
        }

        public PartialViewResult FilterByFaultID(Guid faultID)
        {
            List<FaultsView> faultlogs = new FaultsServ.FaultsServiceClient().FilterByFaultID(faultID).ToList();
            return PartialView("_logentry", faultlogs);
        }

        public PartialViewResult FilterByClientID(string username)
        {
            List<FaultsView> clientlogs = new FaultsServ.FaultsServiceClient().FilterByClientID(username).ToList();
            return PartialView("_logentry", clientlogs);
        }

        public PartialViewResult FilterAll(Guid faultID, string username, DateTime startDate, DateTime endDate)
        {
            List<FaultsView> logs = new FaultsServ.FaultsServiceClient().FilterAll(faultID, username, startDate, endDate);
            return PartialView("_logentry", logs);
        }
    }
}
